<?php
/**
 * 物件詳細用関数<br />
 *
 * @package apamanshop
 * @author　
 * @copyright　
 */
class Rstdtl_Model_Bukendtl extends Rstdtl_Model_Base {

	// DBコネクション
	private $_db;

	/**
	 * コンストラクタ
	 */
	function __construct() {
		$this->_db = $this->getDbConnection();
		//parent::__construct();
	}
	/**
	 * デストラクタ
	 */
	function __destruct() {
		if (!empty($this->_db)) {
			$this->_db->closeConnection();
		}
		//parent::__destruct();
	}

	/**
	* 閲覧履歴Cookei登録
	*/
	public function setReirekiCookie(&$params)
	{
		// モデル生成
		$this->_model_dtlcookie = new Rstdtl_Model_Dtlcookie();

		// 閲覧履歴Cookie登録数取得
		$rirekiCnt = 0;

		if($_COOKIE[Apm_Config_Rstdtl::NAME_COOKIE_RIREKI_CNT] != ""){
			$rirekiCnt = (int)$_COOKIE[Apm_Config_Rstdtl::NAME_COOKIE_RIREKI_CNT];
		}

		if(Apm_Config_Rstdtl::MAX_RIREKI_COOKIES <= $rirekiCnt && ! $this->_model_dtlcookie->isCookie($params['T03_HEYA_CD'],Apm_Config_Rstdtl::NAME_COOKIE_RIREKI,Apm_Config_Rstdtl::MAX_RIREKI_COOKIES)){
			// 最古の履歴を削除
			$this->_model_dtlcookie->DeleteCookie(1,Apm_Config_Rstdtl::NAME_COOKIE_RIREKI,Apm_Config_Rstdtl::NAME_COOKIE_RIREKI_CNT);
		}

		// 閲覧物件登録
		$result = $this->_model_dtlcookie->SetCookie($params['T03_HEYA_CD']
										,Apm_Config_Rstdtl::NAME_COOKIE_RIREKI
										,Apm_Config_Rstdtl::NAME_COOKIE_RIREKI_CNT
										,Apm_Config_Rstdtl::MAX_RIREKI_COOKIES);
	}

	/**
	* QRコード用配列取得
	*/
	public function diffDay($sd,$ed){
		$SecondDiff = $ed - $sd;

		//日数に変換し変換
		return $DayDiff = $SecondDiff / (60 * 60 * 24);

	}

	/**
	* QRコード用配列取得
	*/
	public function getQrArray($url,$size)
	{

		$qrArray = array(
						'url'     => $url,
						'width'   => '500',
						'height'  => '500',
						'img'     => array(
								'alt'     => 'QRコード',
							    'width'   => $size,
							    'height'  => $size
						)
					);

		return $qrArray;
	}

	/**
	* PV増分処理用 GENRU_FLAG取得
	*/
	public function getGenruFlg($params)
	{
		$result = "";

		if(!empty($params['sienJutaku']) && $params['sienJutaku'] == "on")
		{
			// 支援住宅
			$result = 75;
		}
		else
		{
			switch ($params['UseKbn']) {

				case "1":			// 地域情報サイト
					$result = 13;
					break;
				case "2":			// 東急リロケーション
					$result = 15;
					break;
				case "3":			// nifty
					$result = 16;
					break;
				default:
					if(array_key_exists('OemCd', $params) && $params['OemCd'] != "" ){
						$result = 17;	// OEM
					}else{
						$result = 0;	// 通常HP
					}

			}
		}

		return $result;
	}

	/**
	* 物件詳細件数取得
	*/
	public function getBukenDtlCount($params)
	{
		$db_params = array();

		$sql = "";
		$sql .= 'SELECT count(*) TOTAL_COUNT FROM (';
		$sql .= $this->generateDtlSql($params, $db_params);
		$sql .= " ) ";

		$data = array();
		$data = $this->dbGetData($sql, $db_params, $this->_db);
		return (int)$data['TOTAL_COUNT'];
	}

	/**
	* 物件詳細データ取得
	*/
	public function getBukenDtlData($params)
    {
		$db_params = array();
		$sql = $this->generateDtlSql($params, $db_params);

        return $this->dbGetData($sql, $db_params, $this->_db);
    }

	/**
	* 物件詳細データ一覧取得
	*/
	public function getBukenDtlListData($params)
    {
		$db_params = array();

		$sql = "";
		$sql .= $this->generateDtlSql($params, $db_params);
        return $this->dbGetList($sql, $db_params, $this->_db);
    }

	/**
	* 同一建屋の部屋取得
	*
	* 物件詳細検索用SQL文の取得を行う
	* @access	public
	* @param	array
	* @param	array
	* @return	string 物件詳細検索用SQL
	*/
	public function getTateyaHeya($params)
	{
		$db_params = array();
		$result = array();

		// 同一建屋の部屋取得SQL
		$sql = $this->generateTateyaHeyaSql($params, $db_params);
		$temp = $this->dbGetList($sql, $db_params, $this->_db);

		if(!empty($temp)){
			foreach($temp as $data){
				// 部屋番号と家賃が同一のもの以外を配列に格納
				if(! ($heya ==  $data["T03_HEYA_BANGOU"] && $yachin ==  $data["T03_YACHIN"])){
					$result[] = $data;
				}
				$heya =  $data["T03_HEYA_BANGOU"];
				$yachin = $data["T03_YACHIN"];
			}
		}

		return $result;
	}

    /**
	* 複数パラメータのWhere句連結処理
	* @access	public
	* @param	array
	* @param	array (参照渡し)
	* @return	string
	*/
	public function createWhere($params,&$db_params)
	{
		$id = array();

		// 対象パラメータが配列か否か
		if(is_array($params)){
			$id = $params;

		}else{
			$id = explode( ",",$params);
		}

		// 部屋CDをカンマ区切りにする
		$strId='';
		$strComma="";
		for ($i = 0; $i < count($id); $i++)
		{
			$db_params['strId_'.$i] = $id[$i];

			if( 0 == $i ){
				$strComma = "";
			}else{
				$strComma = ",";
			}

			$strId .= $strComma.' :strId_'.$i.' ';
		}

		return $strId;
	}

   /**
	* 物件詳細データを表示用に変換
	*
	* @access	public
	* @param	array ※参照渡し
	* @return	void
	*/
	public function convertData($_config,&$bukenData,$param)
	{

		// OEM判定
		$OemFlg = $this->isOem($param);
		// 法人判定
		$AsnnetFlg = $this->isAsnnet($param);

		// 家電部屋URL
		$kadenUrl = Apm_Bukkenitems::GetKadenUrl($param['isMobile'],$this->_db);

		$searchLoader = new Zend_Application_Module_Autoloader(array(
			'namespace' => 'Search',
			'basePath' => APPLICATION_PATH . '/modules/search',
		));

		$selcyoModel = new Search_Model_Selcyo();  //市区町村
		$cached = array();  //市区町村キャッシュ

		for($i=0;$i<count($bukenData);$i++){
			if($OemFlg == 1){
				// OEM・法人判定
				$bukenData[$i]["OEM_ASNNET"] = "true";
			}else if($AsnnetFlg == 1){
				// OEM・法人判定
				$bukenData[$i]["OEM_ASNNET"] = "true";
			}else{
				// OEM・法人判定
				$bukenData[$i]["OEM_ASNNET"] = "false";
			}
			// 賃料変換
			$bukenData[$i]["CONVERT_T03_YACHIN"] = Apm_Bukkenitems::GetChinryouStr($bukenData[$i]);
			// めやす賃料
			$bukenData[$i]["CONVERT_T03_MEYASU_CHINRYO"] = Apm_Bukkenitems::GetMeyashuTinryoStr($bukenData[$i],$OemFlg);
			$bukenData[$i]["CONVERT_T03_MEYASU_CHINRYO2"] = Apm_Bukkenitems::GetMeyashuTinryoStr($bukenData[$i],$OemFlg,true);
			// 平米単価
			$bukenData[$i]["CONVERT_T03_HEIBEI_TANKA"] = Apm_Bukkenitems::GetHeibeiTankaStr($bukenData[$i]);
			$bukenData[$i]["CONVERT_T03_HEIBEI_TANKA2"] = Apm_Bukkenitems::GetHeibeiTankaStr($bukenData[$i], true);
			// 管理費・共益費
			$bukenData[$i]["CONVERT_T03_KYOUEKIHI"] = Apm_Bukkenitems::GetKyouekihiStr($bukenData[$i],1);
			// 敷金
			$bukenData[$i]["CONVERT_T03_SHIKIKIN"] = Apm_Bukkenitems::GetShikikinStr($bukenData[$i]);
			// 礼金・権利金
			$bukenData[$i]["CONVERT_T03_REIKIN"] = Apm_Bukkenitems::GetReikinStr($bukenData[$i]);
			// 保証金
			$bukenData[$i]["CONVERT_T03_HOSHOUKIN"] = Apm_Bukkenitems::GetHoshoukinStr($bukenData[$i]);
			// 償却・敷引
			$bukenData[$i]["CONVERT_T03_SHOUKYAKUKIN"] = Apm_Bukkenitems::GetShoukyakukinStr($bukenData[$i]);
			// 初期費用
			$bukenData[$i]["CONVERT_T03_SHOKI_HIYO"] = Apm_Bukkenitems::GetSyokiHiyouStr($bukenData[$i],$OemFlg);
			// 間取り
			$bukenData[$i]["CONVERT_T03_MADORI"] = $this->changeValue($bukenData[$i]["T03_MADORI"],"-");
			// 専有面積
			$bukenData[$i]["CONVERT_T03_SENYUU_MENSEKI"] = Apm_Bukkenitems::GetSenyuuMensekiStr($bukenData[$i]);
			// 築年月
			$bukenData[$i]["CONVERT_T03_KANSEINEN_TSUKI"] = Apm_Bukkenitems::GetBuildYmStr($bukenData[$i]);
			// 築年数

			// 物件一覧と物件詳細とで名前が異なるため、詰め直す
			$bukenData[$i]['T03_TIKU_NENSU'] = &$bukenData[$i]['TIKUNENSU'];
			$bukenData[$i]["CONVERT_T03_KANSEINEN"] = Apm_Bukkenitems::GetBuildYStr($bukenData[$i]);

			//if($bukenData[$i]["TIKUNENSU"] =< 0){
			//	$bukenData[$i]["CONVERT_T03_KANSEINEN"] = "-";
			//}else{
			//	$bukenData[$i]["CONVERT_T03_KANSEINEN"] = $bukenData[$i]["TIKUNENSU"]."年";
			//}

			// 問い合わせNo
			$bukenData[$i]["CONVERT_T03_ORIGINAL_HEYA_CD01"] = Apm_Bukkenitems::GetToiawaseNo($bukenData[$i]);

			if($bukenData[$i]["T02_KOUSHIN_STAFF_NEME"] <> "APS_USER" ){
				// 情報公開日
				$bukenData[$i]["CONVERT_T03_TOUROKUBI"] = date("Y/m/d",strtotime($bukenData[$i]["T03_TOUROKUBI"]));
				// 更新日
				$bukenData[$i]["CONVERT_T03_KOUSHINBI"] = date("Y/m/d", strtotime($bukenData[$i]["T03_TOUROKUBI"]." +14 day"));

				// 後何日
				$bukenData[$i]["DIFF_DAY"] =  $this->diffDay( strtotime("today") ,  strtotime($bukenData[$i]["T03_TOUROKUBI"]." +14 day"));

			}else{
				// 情報公開日
				$bukenData[$i]["CONVERT_T03_TOUROKUBI"] = date("Y/m/d");
				// 更新日
				// 2011/03/24 APS物件の場合の更新修正（本日＋2日）
//				$bukenData[$i]["CONVERT_T03_KOUSHINBI"] = date("Y/m/d", strtotime($bukenData[$i]["T03_TOUROKUBI"]." +2 day"));
				$bukenData[$i]["CONVERT_T03_KOUSHINBI"] = date("Y/m/d", strtotime(date('Ymd')." +2 day"));

				// 後何日
				$bukenData[$i]["DIFF_DAY"] =  $this->diffDay(  strtotime("today") , strtotime(date('Ymd')." +2 day"));
			}
			// 住所
			$bukenData[$i]["CONVERT_T03_JYUUSHO_TEXT"] = Apm_Bukkenitems::GetAddressStr($bukenData[$i]);
			//$bukenData[$i]["CONVERT_T03_JYUUSHO_TEXT"] = $this->changeValue($bukenData[$i]["T03_JYUUSHO_TEXT"],"－");
			// 交通1
			$bukenData[$i]["CONVERT_T03_KOUTSU_STR01"] = Apm_Bukkenitems::GetTrafficStr2($bukenData[$i]);
			// 交通2
			$bukenData[$i]["CONVERT_T03_KOUTSU_STR02"] = Apm_Bukkenitems::GetTrafficStr2($bukenData[$i],"02");
			// 交通3
			$bukenData[$i]["CONVERT_T03_KOUTSU_STR03"] = Apm_Bukkenitems::GetTrafficStr2($bukenData[$i],"03");
			if($OemFlg != 1 && $AsnnetFlg != 1) {
				// 交通1(PC用)
				$bukenData[$i]["CONVERT_T03_KOUTSU_STR01_PC"] = Apm_Bukkenitems::GetTrafficStr2($bukenData[$i], "01", $this->_db);
				// 交通2(PC用)
				$bukenData[$i]["CONVERT_T03_KOUTSU_STR02_PC"] = Apm_Bukkenitems::GetTrafficStr2($bukenData[$i], "02", $this->_db);
				// 交通3(PC用)
				$bukenData[$i]["CONVERT_T03_KOUTSU_STR03_PC"] = Apm_Bukkenitems::GetTrafficStr2($bukenData[$i], "03", $this->_db);
			} else {
				// 交通1(PC用)
				$bukenData[$i]["CONVERT_T03_KOUTSU_STR01_PC"] = $bukenData[$i]["CONVERT_T03_KOUTSU_STR01"];
				// 交通2(PC用)
				$bukenData[$i]["CONVERT_T03_KOUTSU_STR02_PC"] = $bukenData[$i]["CONVERT_T03_KOUTSU_STR02"];
				// 交通3(PC用)
				$bukenData[$i]["CONVERT_T03_KOUTSU_STR03_PC"] = $bukenData[$i]["CONVERT_T03_KOUTSU_STR03"];
			}
			// 沿線1
			$bukenData[$i]["CONVERT_T03_ENSEN_NAME"] = Apm_Bukkenitems::GetRailStr($bukenData[$i]);
			// 駅1
			$bukenData[$i]["CONVERT_T03_EKI"] = Apm_Bukkenitems::GetStationStr($bukenData[$i]);
			// 駅1URL
			if($OemFlg != 1 && $AsnnetFlg != 1) {
				$bukenData[$i]["CONVERT_T03_EKI_URL"] = Apm_Bukkenitems::GetStationUrl($bukenData[$i],"01",$this->_db);
			}
			// バス停1
			$bukenData[$i]["CONVERT_T03_BUS_STOP"] = Apm_Bukkenitems::GetBusStopStr($bukenData[$i]);
			// バス乗車
			$bukenData[$i]["CONVERT_T03_BUS_JYOUSHA"] = Apm_Bukkenitems::GetBusRideStr($bukenData[$i]);
			// 徒歩1
			$bukenData[$i]["CONVERT_T03_TOHO01"] = Apm_Bukkenitems::GetWalkStr($bukenData[$i]);
			// 沿線2
			$bukenData[$i]["CONVERT_T03_ENSEN_NAME02"] = Apm_Bukkenitems::GetRailStr($bukenData[$i],"02");
			// 駅2
			$bukenData[$i]["CONVERT_T03_EKI02"] = Apm_Bukkenitems::GetStationStr($bukenData[$i],"02");
			// 駅2URL
			if($OemFlg != 1 && $AsnnetFlg != 1) {
				$bukenData[$i]["CONVERT_T03_EKI02_URL"] = Apm_Bukkenitems::GetStationUrl($bukenData[$i],"02",$this->_db);
			}
			// バス停2
			$bukenData[$i]["CONVERT_T03_BUS_STOP02"] = Apm_Bukkenitems::GetBusStopStr($bukenData[$i],"02");
			// バス乗車2
			$bukenData[$i]["CONVERT_T03_BUS_JYOUSHA02"] = Apm_Bukkenitems::GetBusRideStr($bukenData[$i],"02");
			// 徒歩2
			$bukenData[$i]["CONVERT_T03_TOHO02"] = Apm_Bukkenitems::GetWalkStr($bukenData[$i],"2");
			// 沿線3
			$bukenData[$i]["CONVERT_T03_ENSEN_NAME03"] = Apm_Bukkenitems::GetRailStr($bukenData[$i],"03");
			// 駅3
			$bukenData[$i]["CONVERT_T03_EKI03"] = Apm_Bukkenitems::GetStationStr($bukenData[$i],"03");
			// 駅3URL
			if($OemFlg != 1 && $AsnnetFlg != 1) {
				$bukenData[$i]["CONVERT_T03_EKI03_URL"] = Apm_Bukkenitems::GetStationUrl($bukenData[$i],"03",$this->_db);
			}
			// バス停3
			$bukenData[$i]["CONVERT_T03_BUS_STOP03"] = Apm_Bukkenitems::GetBusStopStr($bukenData[$i],"03");
			// バス乗車3
			$bukenData[$i]["CONVERT_T03_BUS_JYOUSHA03"] = Apm_Bukkenitems::GetBusRideStr($bukenData[$i],"03");
			// 徒歩3
			$bukenData[$i]["CONVERT_T03_TOHO03"] = Apm_Bukkenitems::GetWalkStr($bukenData[$i],"3");
			// 建物構造
			$bukenData[$i]["CONVERT_T03_TATEMONO_KOUZOU"] = $this->changeValue($bukenData[$i]["T03_TATEMONO_KOUZOU"],"－");
			// 建物種別
			$bukenData[$i]["CONVERT_T03_TATEMONO_TYPE"] = $this->changeValue($bukenData[$i]["T03_TATEMONO_TYPE"],"－");
			// 総戸数
			$bukenData[$i]["CONVERT_T03_KOSUU"] = Apm_Bukkenitems::GetBuildRoomNumStr($bukenData[$i]);
			// 間取り詳細
			$bukenData[$i]["CONVERT_T03_MADORI_SHOUSAI"] = Apm_Bukkenitems::GetMadoriShousaiStr($bukenData[$i]);
			// 階建/階
			$bukenData[$i]["CONVERT_T03_KAIDATE"] = Apm_Bukkenitems::GetKaidateKaiStr($bukenData[$i]);
			// 部屋向き
			$bukenData[$i]["CONVERT_T03_HOUGAKU"] = Apm_Bukkenitems::GetHeyamukiStrSimple($bukenData[$i]);
			// 駐車場
			$bukenData[$i]["CONVERT_T03_CHUUSHAJYOU"] = Apm_Bukkenitems::GetParkingStr($bukenData[$i]);
			// 住宅保険
			$bukenData[$i]["CONVERT_T03_HOKENRYOU"] = Apm_Bukkenitems::GetHokenStr($bukenData[$i]);
			// 入居予定日
			$bukenData[$i]["CONVERT_T03_NYUUKYO_YOTEIBI"] = Apm_Bukkenitems::GetNyuukyoZikiStr($bukenData[$i]);
			// 保証会社
			$bukenData[$i]["CONVERT_T03_HOSYOGAISYA"] = Apm_Bukkenitems::GetHosyogaisyaStr($bukenData[$i]);
			// 条件等
			$bukenData[$i]["CONVERT_T03_NYUUKYO_JYOUKEN"] = Apm_Bukkenitems::GetNyuukyoJyoukenStr($bukenData[$i]);
			// その他費用(初期)
			$bukenData[$i]["CONVERT_T03_SONOTAHIYO_SYOKI"] = Apm_Bukkenitems::GetSonotaSyokiHiyo($bukenData[$i]);
			// その他費用(月額)
			$bukenData[$i]["CONVERT_T03_SONOTAHIYO_TUKI"] = Apm_Bukkenitems::GetSonotaTukiHiyo($bukenData[$i]);
			// 設備等
			$bukenData[$i]["CONVERT_T03_SETSUBI"] = Apm_Bukkenitems::GetSetsubiStr($bukenData[$i]);
			// その他条件
			$bukenData[$i]["CONVERT_T03_SONOTA_JYOKEN"] = Apm_Bukkenitems::GetSonotaInfoStr($bukenData[$i]);
			// PRコメント文字
			$bukenData[$i]["CONVERT_T03_PR"] = Apm_Bukkenitems::GetOtakaraPRComment($bukenData[$i],$this->_db);
			//フリーレントアイコン
			$bukenData[$i]['T03_FREERENT_ICON'] = Apm_Bukkenitems::GetFreerentIcon($bukenData[$i], $OemFlg);
			//フリーレント期間
			$bukenData[$i]['CONVERT_FREERENT_KIKAN'] = Apm_Bukkenitems::GetFreerentKikan($bukenData[$i]);
			//部屋割りアイコン
			$bukenData[$i]['T03_HEYAWARI_ICON'] = Apm_Bukkenitems::GetHeyawariIcon($bukenData[$i], $OemFlg);
			//部屋割り期間
			$bukenData[$i]['CONVERT_HEYAWARI_KIKAN'] = Apm_Bukkenitems::GetHeyawariKikan($bukenData[$i]);
			// ダブルゼロ
			$bukenData[$i]["CONVERT_DOBLEZERO"] = Apm_Bukkenitems::GetDoblezeroNo($bukenData[$i],$this->_db);
			// 2010/12/29 ダブルゼロアイコン
			$bukenData[$i]['T03_BOUBLEZERO_ICON'] = Apm_Bukkenitems::GetBoubleZeroIcon($bukenData[$i]);
			// 新築アイコン
			$bukenData[$i]["T03_SHINCHIKU_ICON"] = Apm_Bukkenitems::GetShinchikuIcon($bukenData[$i]);

			// お宝データ
			//$bukenData[$i]["CONVERT_OTAKARA"] = Apm_Bukkenitems::GetOtakaraData($bukenData[$i],$this->_db);
			// 家電ワード
			$bukenData[$i]['CONVERT_KADEN'] = Apm_Bukkenitems::GetKadenWord($bukenData[$i]);
			$bukenData[$i]['CONVERT_KADEN_URL'] = $kadenUrl;

			// UPDATE Start 2011/06/30 AKBキャンペーン対応 SS sakakibara-y
			//適用キャンペーンCD、キャンペーン名、キャンペーンURLリストを取得
			$bukenData[$i]['APPLY_CAMPAIGN_LIST'] = Apm_Bukkenitems::GetCampaignList($bukenData[$i][T03_HEYA_CD], $param['isMobile']);
			//print_r($bukenData[$i]['APPLY_CAMPAIGN_LIST']);
			// UPDATE End 2011/06/30 AKBキャンペーン対応 SS sakakibara-y

			// 周辺地図緯度
			$bukenData[$i]["MAP_IDO"] = $bukenData[$i]["T03_IDO"];
			if(is_null($bukenData[$i]["MAP_IDO"]) or $this->changeValue($bukenData[$i]["T03_KOUKOKU_KAISHA_CD"],"") <> "AOS"){
				$bukenData[$i]["MAP_IDO"] = $bukenData[$i]["M01_IDO"];
			}
			// 周辺地図経度
			$bukenData[$i]["MAP_KEIDO"] = $bukenData[$i]["T03_KEIDO"];
			if(is_null($bukenData[$i]["MAP_KEIDO"]) or $this->changeValue($bukenData[$i]["T03_KOUKOKU_KAISHA_CD"],"") <> "AOS"){
				$bukenData[$i]["MAP_KEIDO"] = $bukenData[$i]["M01_KEIDO"];
			}
			// 物件画像取得
			$bukenData[$i]["BUKEN_IMAGE"] = Apm_Bukkenitems::GetImageDataMain($bukenData[$i],$OemFlg);
			// モバイル物件詳細URL
			$bukenData[$i]["MOBILE_URL"] = $_config['apm']['baseurl'].Apm_Config_Rstdtl::URL_MOBILE_BUKENDTL."?bj=bj05%26heyacode=".$bukenData[$i]["T03_HEYA_CD"];

			//交通機関01
			$bukenData[$i]['KOUSTU_KIKAN_STR01'] = Apm_Bukkenitems::GetTrafficStr($bukenData[$i]);
			//NEWアイコン
			$bukenData[$i]['NEW_ICON']           = Apm_Bukkenitems::GetNewIcon($bukenData[$i]);
			//フリーレントアイコン
			$bukenData[$i]['FREERENT_ICON']      = Apm_Bukkenitems::GetFreerentIcon($bukenData[$i], $OemFlg);
			//部屋割りアイコン
			$bukenData[$i]['HEYAWARI_ICON']      = Apm_Bukkenitems::GetHeyawariIcon($bukenData[$i], $OemFlg);
			//ダブル０アイコン
			$bukenData[$i]['BOUBLEZERO_ICON']    = Apm_Bukkenitems::GetBoubleZeroIcon($bukenData[$i]);
			//画像満載アイコン
			$bukenData[$i]['FULLGAZOU_ICON']     = Apm_Bukkenitems::GetFullGazouIcon($bukenData[$i]['BUKEN_IMAGE']);

			// 無料電話番号
			$bukenData[$i]['CONVERT_CONNECTION_NO'] = '';
			$tempData = Apm_ShopUtil::getCallingData($bukenData[$i], Apm_Config_Shop::FREE_CONNECTION_NO_1);
			if ($tempData['IS_FREE_CALL']) {
				$bukenData[$i]['FREE_CALLING'] = $tempData['TEL_01'];
				$bukenData[$i]['CONVERT_CONNECTION_NO'] = Apm_Bukkenitems::GetBukkenWebCallingNo($bukenData[$i], Apm_Config_Rstdtl::CAMPAIGN_PC, $this->_db);
			}

			// 店舗詳細URL
			$bukenData[$i]['SHOP_DTL_URL'] = Apm_Bukkenurl::generateUrlByParametersShopDetail($bukenData[$i]);

			$bukenData[$i]['LINE_URL'] = Apm_Config_Shop::URL_LINE;
			$bukenData[$i]['M05_TENPO_LINE_ID'] = Apm_ShopUtil::getTenpoLineId($bukenData[$i]['T03_TENPO_CD']);

			// 支援住宅フラグ
			$bukenData[$i]["CONVERT_SIEN_JUTAKU_FLG"] = Apm_Bukkenitems::GetShienjutakuFlg($bukenData[$i]);
			// 支援提供普通借家区分
			$bukenData[$i]["SIEN_HUTU_KBN"] = Apm_Bukkenitems::GetSaigaiHutuKbn($bukenData[$i]);
			// 支援提供定期借家
			$bukenData[$i]["SIEN_TEIKI_ICON"] = Apm_Bukkenitems::GetSaigaiTeikiIcon($bukenData[$i]);
			// 災害特別優遇物件
			$bukenData[$i]["SIEN_YUGU_ICON"] = Apm_Bukkenitems::GetSaigaiYuguIcon($bukenData[$i]);
			// 災害特別優遇備考
			$bukenData[$i]["SIEN_YUGU_BIKO"] = Apm_Bukkenitems::GetSaigaiYuguBiko($bukenData[$i]);
			// 都道府県
			$bukenData[$i]["T03_TODOUFUKEN_STR"] = Apm_Config_Shop::$PREF_LIST[$bukenData[$i]['T03_TODOUFUKEN_CD']];
			// 市区町村
			$prefCd = $bukenData[$i]['T03_TODOUFUKEN_CD'];
			$cityCd = $prefCd . $bukenData[$i]['T03_SHIKUCHOUSON_CD'];
			if (array_key_exists($cityCd, $cached)) {
				$bukenData[$i]['T03_SHIKUCHOUSON_STR'] = $cached[$cityCd];
			} else {
				$params = array();
				$params['PrefCd'] = array($prefCd);
				$params['CityCd'] = array($cityCd);
				$shiku = $selcyoModel->getShikucyosonNameByShikucyosonCd($params);
				$bukenData[$i]['T03_SHIKUCHOUSON_STR']   = $shiku[0]['M01_SHIKUCHOUSON_ALIAS'];
				$cached[$cityCd] = $shiku[0]['M01_SHIKUCHOUSON_ALIAS'];
			}

		}
	}

	/**
	* 同一建屋の部屋取得SQL
	*
	* @access	public
	* @param	array
	* @return	string 同一建屋の部屋取得SQL
	*/
	public function generateTateyaHeyaSql($params,&$db_params)
	{
		$db_params["tatemonoCd"] = $params["T03_TATEMONO_CD"];
		$db_params["heyaCd"] = $params["T03_HEYA_CD"];

		$sql = "";
		$sql .= "SELECT";
		$sql .= "        T03_YACHIN";
		$sql .= "        ,T03_YACHIN_TAX";
		$sql .= "        ,T03_HEYA_BANGOU";
		$sql .= "        ,T03_KYOUEKIHI";
		$sql .= "        ,T03_KYOUEKIHI_TAX";
		$sql .= "        ,T03_KANRIHI";
		$sql .= "        ,T03_KANRIHI_TAX";
		$sql .= "        ,T03_MADORI";
		$sql .= "        ,T03_SENYUU_MENSEKI";
		$sql .= "        ,T03_HEYA_CD";
		$sql .= "    FROM";
		$sql .= "        T03WEB_HEYA";
		$sql .= "    WHERE";
		$sql .= "        T03_TATEMONO_CD = :tatemonoCd ";
		$sql .= "        AND T03_HEYA_CD <> :heyaCd ";
		$sql .= "    ORDER BY";
		$sql .= "        T03_HEYA_BANGOU";
		$sql .= "        ,T03_YACHIN";

		return $sql;
	}

    /**
     * 物件詳細検索用SQL文の取得
     *
     * 物件詳細検索用SQL文の取得を行う
     * @access	public
     * @param	array
     * @param	array
     * @return	string 物件詳細検索用SQL
     */
    public function generateDtlSql($params,&$db_params)
    {
		$where_id = $this->createWhere($params["ID"],$db_params);

		$sql = "";
		$sql .= " SELECT";
		$sql .= "         T03.*";
		$sql .= "         ,TRUNC(MONTHS_BETWEEN(sysdate,";
		$sql .= "                               TO_DATE(LPAD(TO_CHAR(NVL(T03_KANSEINEN, '00')), 4, '0') ";
		$sql .= "                                      || LPAD(TO_CHAR(NVL(T03_KANSEITSUKI, '00')), 2, '0') ";
		$sql .= "                                      || LPAD(TO_CHAR(NVL(T03_KANSEIBI, '01')), 2, '0'), 'yyyy.mm.dd')) / 12) AS TIKUNENSU";
		$sql .= "         ,ROWNUM AS LINE";
		$sql .= "         ,CASE";
		$sql .= "             WHEN T03_SHIKIKIN_TSUKISUU IS NULL THEN T03_SHIKIKIN";
		$sql .= "             ELSE TO_NUMBER(NVL(T03_SHIKIKIN_TSUKISUU, 0)) * TO_NUMBER(NVL(T03_YACHIN, 0))";
		$sql .= "         END AS T03_SHIKIKIN_COMP";
		$sql .= "         ,CASE";
		$sql .= "             WHEN T03_REIKIN_TSUKISUU IS NULL THEN T03_REIKIN";
		$sql .= "             ELSE TO_NUMBER(NVL(T03_REIKIN_TSUKISUU, 0)) * TO_NUMBER(NVL(T03_YACHIN, 0))";
		$sql .= "         END AS T03_REIKIN_COMP";
		$sql .= "         ,CASE";
		$sql .= "             WHEN T03_HOSHOUKIN_TSUKISUU IS NULL THEN T03_HOSHOUKIN";
		$sql .= "             ELSE TO_NUMBER(NVL(T03_HOSHOUKIN_TSUKISUU, 0)) * TO_NUMBER(NVL(T03_YACHIN, 0))";
		$sql .= "         END AS T03_HOSHOUKIN_COMP";
		$sql .= "         ,CASE";
		$sql .= "             WHEN T03_SHOUKYAKUKIN_TSUKISUU IS NULL THEN T03_SHOUKYAKUKIN";
		$sql .= "             ELSE TO_NUMBER(NVL(T03_SHOUKYAKUKIN_TSUKISUU, 0)) * TO_NUMBER(NVL(T03_YACHIN, 0))";
		$sql .= "         END AS T03_SHOUKYAKUKIN_COMP";
		$sql .= "         ,CASE";
		$sql .= "             WHEN (";
		$sql .= "                 ((sysdate - 7) < T03_KOUSHINBI)";
		$sql .= "                 AND (T03_KIGENGIRE_SHUUSEI_FLAG <> 1)";
		$sql .= "             ) THEN 0";
		$sql .= "             ELSE 1";
		$sql .= "         END AS SHINCHAKU_FLAG";
		$sql .= "         ,DECODE(TRIM(NVL(T03_GAIKAN_GAZOU01, ''))";
		$sql .= "             ,'', 1";
		$sql .= "             ,0";
		$sql .= "         ) GAIKAN_UMU_FLAG";
		$sql .= "         ,DECODE(TRIM(NVL(T03_MADORIZU, ''))";
		$sql .= "             ,'', 1";
		$sql .= "             ,0";
		$sql .= "         ) MADORI_UMU_FLAG";
		$sql .= "         ,CASE";
		$sql .= "             WHEN (";
		$sql .= "                 (";
		$sql .= "                     TRIM(NVL(T03_NAISOU_GAZOU01, '')) IS NOT NULL";
		$sql .= "                 )";
		$sql .= "                 OR (";
		$sql .= "                     TRIM(NVL(T03_NAISOU_GAZOU02, '')) IS NOT NULL";
		$sql .= "                 )";
		$sql .= "                 OR (";
		$sql .= "                     TRIM(NVL(T03_NAISOU_GAZOU03, '')) IS NOT NULL";
		$sql .= "                 )";
		$sql .= "                 OR (";
		$sql .= "                     TRIM(NVL(T03_NAISOU_GAZOU04, '')) IS NOT NULL";
		$sql .= "                 )";
		$sql .= "             ) THEN 0";
		$sql .= "             ELSE 1";
		$sql .= "         END AS NAISOU_UMU_FLAG";
		$sql .= "         ,DECODE(TRIM(NVL(T03_PANORAMA_GAZOU01, ''))";
		$sql .= "             ,'', 1";
		$sql .= "             ,0";
		$sql .= "         ) PANORAMA1_UMU_FLAG";
		$sql .= "         ,DECODE(TRIM(NVL(T03_PANORAMA_GAZOU02, ''))";
		$sql .= "             ,'', 1";
		$sql .= "             ,0";
		$sql .= "         ) PANORAMA2_UMU_FLAG";
		$sql .= "         ,M05.M05_TENPO_CD";
		$sql .= "         ,M05.M05_TENPO_TEL01";
		$sql .= "         ,M05_JYUUSHO_TEXT";
		$sql .= "         ,M05_TENPO_BANCHI";
		$sql .= "         ,M05_TENPO_JYUUSHO_BIKOU";
		$sql .= "         ,M05.M05_MAP";
		$sql .= "         ,M05.M05_HOUZINMEI";
		$sql .= "         ,M05.M05_MENKYO_HAKKOUMOTO";
		$sql .= "         ,M05.M05_MENKYO_KOUSHINKAI";
		$sql .= "         ,M05.M05_MENKYO_GOUSUU";
		$sql .= "         ,M01_CHOUMEI || M01_CHOUMOKU as M01_JYUUSHO";
		$sql .= "         ,M01.M01_IDO / 3600000 AS M01_IDO";
		$sql .= "         ,M01.M01_KEIDO / 3600000 AS M01_KEIDO";
		$sql .= "         ,SUBSTR(LPAD(TO_CHAR(TO_NUMBER(SUBSTR(M05_TENPO_CD, 3, 1)) + TO_NUMBER(SUBSTR(M05_TENPO_CD, 4, 1)) + TO_NUMBER(SUBSTR(M05_TENPO_CD, 5, 1)) + TO_NUMBER(SUBSTR(M05_TENPO_CD, 6, 1)) + TO_NUMBER(SUBSTR(M05_TENPO_CD, 7, 1)) + TO_NUMBER(SUBSTR(M05_TENPO_CD, 8, 1)) + TO_NUMBER(TO_CHAR(SYSDATE, 'SS'))), 3, '0'), 3, 1) AS RANDOM_INDEX";
		$sql .= "         ,T02.T02_KOUSHIN_STAFF_NEME";
		for ($call_no=1; $call_no<=Apm_Config_Shop::CALLNOTE_NO_MAX; $call_no++) {
			$sql .= "     ,M93.M93_CONNECTION_NO".$call_no;
			$sql .= "     ,M93.M93_CONTROL_FLAG".$call_no;
		}
		$sql .= "         ,M93.M93_USE_KBN";
		$sql .= "         ,M93.M93_START_DATE";
		$sql .= "         ,M93.M93_DEL_DATE";
		$sql .= "         ,M03_1.M03_ROSENZU_EKI_CD AS ROSENZU_EKI_CD01";
		$sql .= "         ,M03_2.M03_ROSENZU_EKI_CD AS ROSENZU_EKI_CD02";
		$sql .= "         ,M03_3.M03_ROSENZU_EKI_CD AS ROSENZU_EKI_CD03";
		// start
		$sql .= "         ,T03.T03_SETSUBI16              as T03_SETSUBI16_ICON";
		$sql .= "         ,T03.T03_SETSUBI63              as T03_SETSUBI63_ICON";
		$sql .= "         ,T03.T03_SETSUBI03              as T03_SETSUBI03_ICON";
		$sql .= "         ,T03.T03_SETSUBI34              as T03_SETSUBI34_ICON";
		$sql .= "         ,T03.T03_SETSUBI35              as T03_SETSUBI35_ICON";
		$sql .= "         ,T03.T03_SETSUBI08              as T03_SETSUBI08_ICON";
		$sql .= "         ,T03.T03_SETSUBI09              as T03_SETSUBI09_ICON";
		$sql .= "         ,T03.T03_SETSUBI23              as T03_SETSUBI23_ICON";
		$sql .= "         ,T03.T03_SETSUBI98              as T03_SETSUBI98_ICON";
		$sql .= "         ,T03.T03_SETSUBI71              as T03_SETSUBI71_ICON";
		$sql .= "         ,T03.T03_NYUUKYO_JYOUKEN12      as T03_NYUUKYO_JYOUKEN12_ICON";
		$sql .= "         ,T03.T03_SETSUBI24              as T03_SETSUBI24_ICON";
		$sql .= "         ,T03.T03_SETSUBI02              as T03_SETSUBI02_ICON";
		$sql .= "         ,T03.T03_SETSUBI64              as T03_SETSUBI64_ICON";
		$sql .= "         ,T03.T03_SETSUBI15              as T03_SETSUBI15_ICON";
		$sql .= "         ,T03.T03_SETSUBI01              as T03_SETSUBI01_ICON";
		$sql .= "         ,T03.T03_SETSUBI57              as T03_SETSUBI57_ICON";
		$sql .= "         ,T03.T03_SETSUBI31              as T03_SETSUBI31_ICON";
		$sql .= "         ,T03.T03_FREERENT_FLAG          as T03_FREERENT_FLAG_ICON";
		$sql .= "         ,T03.T03_NYUUKYO_JYOUKEN02      as T03_NYUUKYO_JYOUKEN02_ICON";
		$sql .= "         ,T03.T03_SETSUBI67              as T03_SETSUBI67_ICON";
		$sql .= "         ,T03.T03_SETSUBI45              as T03_SETSUBI45_ICON";
		$sql .= "         ,T03.T03_SETSUBI29              as T03_SETSUBI29_ICON";
		$sql .= "         ,T03.T03_SETSUBI32              as T03_SETSUBI32_ICON";
		$sql .= "         ,T03.T03_SETSUBI47              as T03_SETSUBI47_ICON";
		$sql .= "         ,T03.T03_NYUUKYO_JYOUKEN03      as T03_NYUUKYO_JYOUKEN03_ICON";
		$sql .= "         ,T03.T03_SETSUBI68              as T03_SETSUBI68_ICON";
		$sql .= "         ,T03.T03_NYUUKYO_JYOUKEN01      as T03_NYUUKYO_JYOUKEN01_ICON";
		$sql .= "         ,T03.T03_SETSUBI43              as T03_SETSUBI43_ICON";
		$sql .= "         ,T03.T03_SETSUBI85              as T03_SETSUBI85_ICON";
		$sql .= "         ,T03.T03_SETSUBI14              as T03_SETSUBI14_ICON";
		$sql .= "         ,T03.T03_NYUUKYO_JYOUKEN10      as T03_NYUUKYO_JYOUKEN10_ICON";
		$sql .= "         ,T03.T03_SETSUBI33              as T03_SETSUBI33_ICON";
		$sql .= "         ,T03.T03_SETSUBI93              as T03_SETSUBI93_ICON";
		$sql .= "         ,T03.T03_SETSUBI83              as T03_SETSUBI83_ICON";
		
		//	CHN2015-10対応
//		$sql .= "         ,case when T03.T03_TOHO01 <= 3 or T03.T03_TOHO02 <= 3 or T03.T03_TOHO03 <= 3 then 1 else 0 end as T03_TOHO_ICON";
		$sql .= "         ,case when (T03.T03_TOHO01 <= 3 and T03.T03_EKI_CD01 IS NOT NULL and T03.T03_BUS_GAISHA IS NULL) or (T03.T03_TOHO02 <= 3 and T03.T03_EKI_CD02 IS NOT NULL and T03.T03_BUS_GAISHA02 IS NULL) or (T03.T03_TOHO03 <= 3 and T03.T03_EKI_CD03 IS NOT NULL and T03.T03_BUS_GAISHA03 IS NULL) then 1 else 0 end as T03_TOHO_ICON";
		$sql .= "         ,T03.T03_SETSUBI70              as T03_SETSUBI70_ICON";
		$sql .= "         ,T03.T03_NYUUKYO_JYOUKEN11      as T03_NYUUKYO_JYOUKEN11_ICON";
		$sql .= "         ,T03.T03_SETSUBI72              as T03_SETSUBI72_ICON";
		$sql .= "         ,T03.T03_SETSUBI82              as T03_SETSUBI82_ICON";
		$sql .= "         ,T03.T03_SETSUBI86              as T03_SETSUBI86_ICON";
		$sql .= "         ,T03.T03_SETSUBI94              as T03_SETSUBI94_ICON";
		$sql .= "         ,T03.T03_SETSUBI61              as T03_SETSUBI61_ICON";
		$sql .= "         ,T03.T03_SETSUBI38              as T03_SETSUBI38_ICON";
		$sql .= "         ,T03.T03_SETSUBI56              as T03_SETSUBI56_ICON";
		// #351 家電部屋キャンペーン対応 Start
		$sql .= "         ,CAM.KADEN_NAME";
		// #351 家電部屋キャンペーン対応 End
		$sql .= "     FROM";
		$sql .= "         T03WEB_HEYA T03";
		$sql .= "         ,M05TENPO_INFO M05";
		$sql .= "         ,M01JYUUSHO M01";
		$sql .= "         ,T02HEYA T02";
		$sql .= '         ,M93CALLNOTE M93';		// 2013/08 WEBCALLING→CALLNOTE 切替
		$sql .= "         ,M03EKI M03_1";
        $sql .= "         ,M03EKI M03_2";
        $sql .= "         ,M03EKI M03_3";
		// #351 家電部屋キャンペーン対応 Start
		//  不要になったら削除する
		$sql .= "         ,(";
		$sql .= "            SELECT";
		$sql .= "                 HEYA_CD";
		$sql .= "                ,substr(sys_connect_by_path(KADEN_NAME,'#'),2) AS KADEN_NAME";
		$sql .= "              FROM";
		$sql .= "                 (";
		$sql .= "                   SELECT";
		$sql .= "                        HEYA_CD";
		$sql .= "                       ,KADEN_NAME";
		$sql .= "                       ,Lag(RowID) over (partition by HEYA_CD order by KADEN_CD) AS LagRowID";
		$sql .= "                       ,count(KADEN_CD) over (partition by HEYA_CD) AS CountKey";
		$sql .= "                     FROM";
		$sql .= "                        (";
		$sql .= "                          SELECT";
		$sql .= "                               CAM.T03_HEYA_CD    AS HEYA_CD";
		$sql .= "                              ,KEY.M94_KADEN_CD   AS KADEN_CD";
		$sql .= "                              ,KEY.M94_KADEN_NAME AS KADEN_NAME";
		$sql .= "                            FROM";
		$sql .= "                               T03WEB_HEYA_CAMPAIGN CAM";
		$sql .= "                              ,M94KADEN KEY";
		$sql .= "                           WHERE";
		$sql .= "                               CAM.T03_HEYA_CD IN ( ".$where_id." )";
		$sql .= "                               AND CAM.T03_CAMPAIGN_CD = " . Apm_Config_Search::KADEN_CAMPAIGN_CD;
		$sql .= "                               AND CAM.T03_OTAKARA_CD = KEY.M94_KADEN_CD";
		$sql .= "                               AND NVL(KEY.M94_INS_DATE,SYSDATE+1) <= SYSDATE";
		$sql .= "                               AND NVL(KEY.M94_DEL_DATE,SYSDATE)   >= SYSDATE";
		$sql .= "                               AND EXISTS (";
		$sql .= "                                   SELECT 1 FROM M94CAMPAIGN M94";
		$sql .= "                                    WHERE CAM.T03_CAMPAIGN_CD = M94.M94_CAMPAIGN_CD";
		$sql .= "                                      AND NVL(M94.M94_START_YMD,'99999999') <= TO_CHAR(SYSDATE,'YYYYMMDD')";
		$sql .= "                                      AND NVL(M94.M94_END_YMD,'99999999')   >= TO_CHAR(SYSDATE,'YYYYMMDD')";
		$sql .= "                                      AND M94.M94_DELETE_FLAG = 0";
		// モバイル
		if(array_key_exists('isMobile', $params) === true)
		{
			$sql .= "                                  AND M94.M94_MOBILE_KBN = '" . $params['isMobile'] . "'";
		}
		// PC
		else
		{
			$sql .= "                                  AND M94.M94_MOBILE_KBN = '0'";
		}
		$sql .= "                               )";
		$sql .= "                        )";
		$sql .= "                 )";
		$sql .= "             WHERE";
		$sql .= "                 LEVEL = CountKey";
		$sql .= "                 start with LagRowID is null";
		$sql .= "                 connect by prior RowID = LagRowID";
		$sql .= "          ) CAM";
		// #351 家電部屋キャンペーン対応 End
		$sql .= "     WHERE";
		$sql .= "         T03.T03_HEYA_CD IN ( ".$where_id." )";
		$sql .= "         AND T03.T03_HEYA_CD = T02.T02_HEYA_CD";
		$sql .= "         AND T03.T03_TENPO_CD = M05.M05_TENPO_CD";
		$sql .= "         AND T03.T03_TODOUFUKEN_CD = M01.M01_TODOUFUKEN_CD";
		$sql .= "         AND T03.T03_SHIKUCHOUSON_CD = M01.M01_SHIKUCHOUSON_CD";
		$sql .= "         AND T03.T03_CHOUMEI_CD = M01.M01_CHOUMEI_CD";
		$sql .= "         AND T03.T03_CHOUMOKU_CD = M01.M01_CHOUMOKU_CD";
		$sql .= "         AND T03.T03_TENPO_CD = M93.M93_TENPO_CD(+)";
		$sql .= "         AND T03.T03_EKI_CD01 = M03_1.M03_EKI_CD(+)";
		$sql .= "         AND T03.T03_EKI_CD02 = M03_2.M03_EKI_CD(+)";
		$sql .= "         AND T03.T03_EKI_CD03 = M03_3.M03_EKI_CD(+)";
		// #351 家電部屋キャンペーン対応 Start
		$sql .= "         AND T03.T03_HEYA_CD = CAM.HEYA_CD(+)";
		// #351 家電部屋キャンペーン対応 End
		$sql .=       $this->getSortOrder($params);

        return $sql;
    }


   /**
	* 物件詳細検索OrderBy句作成
	*
	* @access	public
	* @param	array パラメータ
	* @return	string order by句
	*/

	public function getSortOrder($params)
	{

		$sortOrder = "";

		// ソート基準項目がパラメータに含まれているか
		if(empty($params['sort_col'])){
			// パラメータに含まれていない場合
			$sortOrder = "T03_YACHIN ASC";
		}else{
			// ｿｰﾄ方向性ｾｯﾄ
			if($sortCol_Flg == "0"){
				$sortDrc = "ASC";
			}else{
				$sortDrc = "DESC";
			}

			switch ($sortCol){
				// 新着情報
				case "1":
					$sortOrder = "SHINCHAKU_FLAG ".$sortDrc;
					break;
				// 所在地
				case "2":
					$sortOrder = "T03_JYUUSHO_TEXT ".$sortDrc;
					break;
				// 駅
				case "3":
					$sortOrder = "T03_EKI_NAME ".$sortDrc;
					break;
				// 駅徒歩
				case "4":
					$sortOrder = "NVL( T03_TOHO01, 0) ".$sortDrc;
					break;
				// ﾊﾞｽ徒歩
				case "5":
					$sortOrder = "NVL( T03_BUS_JYOUSHA, 0) ".$sortDrc.", NVL( T03_TOHO01, 0) ".$sortDrc;
					break;
				// 賃料
				case "6":
					$sortOrder = "T03_YACHIN ".$sortDrc;
					break;
				// 敷金
				case "7":
					$sortOrder = "NVL(T03_SHIKIKIN_COMP, 0) ".$sortDrc;
					break;
				// 礼金
				case "8":
					$sortOrder = "NVL(T03_REIKIN_COMP, 0) ".$sortDrc;
					break;
				// 保証
				case "9":
					$sortOrder = "NVL(T03_HOSHOUKIN_COMP, 0) ".$sortDrc;
					break;
				// 償/敷
				case "10":
					$sortOrder = "NVL(T03_SHOUKYAKUKIN_COMP, 0) ".$sortDrc;
					break;
				// 間取り
				case "11":
					$sortOrder = "T03_MADORI_CD ".$sortDrc;
					break;
				// 専有面積
				case "12":
					$sortOrder = "T03_SENYUU_MENSEKI ".$sortDrc;
					break;
				// 建物種別
				case "13":
					$sortOrder = "T03_TATEMONO_TYPE ".$sortDrc;
					break;
				// 築年数
				case "14":
					$sortOrder = "T03_KANSEINEN ".$sortDrc.", T03_KANSEITSUKI ".$sortDrc;
					break;
				// 写真
				case "15":
					$sortOrder = "GAIKAN_UMU_FLAG ".$sortDrc;
					break;
				// 間取り
				case "16":
					$sortOrder = "MADORI_UMU_FLAG ".$sortDrc;
					break;
				// ﾐﾄﾞﾙ
				case "17":
					$sortOrder = "T03_KASHIDASHI_KUBUN ".$sortDrc;
					break;
				// 取扱店舗
				case "18":
					$sortOrder = "T03_TENPO_CD ".$sortDrc;
					break;
				// パノラマ
				case "19":
					$sortOrder = "PANORAMA1_UMU_FLAG ".$sortDrc.", PANORAMA2_UMU_FLAG ".$sortDrc;
					break;
				// 内装
				case "20":
					$sortOrder = "NAISOU_UMU_FLAG ".$sortDrc;
					break;
				// 合計所要時間
				case "21":
					$sortOrder = "T03_KOUKOKU_KAISHA_CD, T03_KOUKOKU_TOIAWASE_NO";
					break;
				// ﾃﾞﾌｫﾙﾄ
				default:
					$sortOrder = "T03_YACHIN ".$sortDrc;
					break;
			}
		}

		$orderBy = " ORDER BY ".$sortOrder.", T03_TOUROKUBI DESC, T03.T03_HEYA_CD ASC";

		return $orderBy;
	}

	/**
	* 部屋コードからPRコメント取得
	*/
	public function getPrCommentByHeyaCd($params)
    {
    	$db_params = array();
        $sql = $this->generatePrCommentByHeyaCdSql($params, $db_params);
        return $this->dbGetData($sql, $db_params, $this->_db);
    }

    /**
     * PRコメント取得用SQL文の取得
     *
     * PRコメント取得SQL文の取得を行う
     * @access	public
     * @param	array
     * @param	array
     * @return	string PRコメント取得SQL
     */
    public function generatePrCommentByHeyaCdSql($params, &$db_params)
    {

        $db_params['heyaCd'] = $params['HeyaCd'];

		$sql = "";
		$sql .= "SELECT ";
		$sql .= "     T03_PR01 ";
		$sql .= "   , T03_PR02 ";
		$sql .= "   , T03_JYUUSHO_TEXT ";
		$sql .= "   , M01_CHOUMEI || M01_CHOUMOKU as M01_JYUUSHO ";
		$sql .= "   , T03_TATEMONO_TYPE ";
		$sql .= "   , T03_MADORI ";
		$sql .= "   , T03_ORIGINAL_HEYA_CD01 || '-' || T03_TENPO_CD as T03_HEYA_CD ";
		//$sql .= "   , T03_HEYA_CD ";
		$sql .= "   , T03_TODOUFUKEN ";
		$sql .= "   , T03_SHIKUCHOUSON ";
		$sql .= "FROM ";
		$sql .= "    T03WEB_HEYA ";
		$sql .= "    LEFT JOIN M01JYUUSHO ";
		$sql .= "        ON (T03_TODOUFUKEN_CD = M01_TODOUFUKEN_CD ";
		$sql .= "        AND T03_SHIKUCHOUSON_CD = M01_SHIKUCHOUSON_CD ";
		$sql .= "        AND T03_CHOUMEI_CD = M01_CHOUMEI_CD ";
		$sql .= "        AND T03_CHOUMOKU_CD = M01_CHOUMOKU_CD) ";
		$sql .= "WHERE ";
		$sql .= "    T03_HEYA_CD = :heyaCd ";

        return $sql;
    }

    /**
     * ﾍﾟｰｼﾞﾋﾞｭｰ情報をDBに書き込む
     *
     * @param vstrTenpoCd  - 店舗CD
     * @param vintKbn      - 表示ﾍﾟｰｼﾞ区分( 0:物件詳細, 1:店舗詳細, 2:問合せﾒｰﾙ)
     * @param vintGFlg     - 表示ﾍﾟｰｼﾞｼﾞｬﾝﾙ区分（0:HP, 1:i-mode, 2:j-sky, 3:ez-web, 4:infogate)
     * @param vstrHeyaCd   - 自社管理部屋CD
     */
    public function S_RegPageViewLog($vstrTenpoCd, $vintKbn, $vintGFlg, $vstrHeyaCd, $vintCount)
    {
    	$db_params = array();

    	$sql = "";
		$sql .="INSERT";
		$sql .="    INTO";
		$sql .="        W21PAGE_VIEW_LOG(";
		$sql .="            W21_TENPO_CD";
		$sql .="            ,W21_KENSAKU_FLAG";
		$sql .="            ,W21_GENRU_FLAG";
		$sql .="            ,W21_ORIGINAL_HEYA_CD";
		$sql .="            ,W21_COUNT";
		$sql .="        )";
		$sql .="    VALUES";
		$sql .="        (";
		$sql .="            '".$vstrTenpoCd."'";
		$sql .="            ,'".$vintKbn."'";
		$sql .="            ,'".$vintGFlg."'";
		$sql .="            ,'".$vstrHeyaCd."'";
		$sql .="            ,'".$vintCount."'";
		$sql .="        )";

		//$db = $this->getDbConnection();
		//$this->_db = $this->getDbConnection();

		//トランザクションStart
		$this->startTransaction($this->_db);

		try {
			$this->dbExecQuery($sql, $db_params, $this->_db);
			// コミット
			$this->commitTransaction($this->_db);
		}catch (Exception $e) {
			//ロールバック
			$this->rollbackTransaction($this->_db);
			//DBのエラーメッセージをログに書き出す
			__log_debug(__FILE__, __LINE__, __METHOD__, $e->getMessage());
		}

		//トランザクションEnd
		//$db->closeConnection();
		//$this->_db->closeConnection();
	}

}
?>